﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Ors.RInterface.Engine.PInvoke
{
    public static class Winapi
    {
        public const uint HKEY_CURRENT_USER = 0x80000001;
        public const uint HKEY_LOCAL_MACHINE = 0x80000002;
        public const uint HKEY_USERS = 0x80000003;
        public const uint HKEY_CURRENT_CONFIG = 0x80000005;
        public const uint HKEY_DYN_DATA = 0x80000006;
        public const uint KEY_QUERY_VALUE = 0x1;
        public const uint KEY_SET_VALUE = 0x2;
        public const uint KEY_CREATE_SUB_KEY = 0x4;
        public const uint KEY_ENUMERATE_SUB_KEYS = 0x8;
        public const uint KEY_NOTIFY = 0x10;
        public const uint KEY_CREATE_LINK = 0x20;
        public const uint KEY_WOW64_32KEY = 0x200;
        public const uint KEY_WOW64_64KEY = 0x100;
        public const uint KEY_WOW64_RES = 0x300;

        public const int ERROR_SUCCESS = 0;
        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "RegOpenKeyEx")]
        public static extern int RegOpenKeyEx(
            uint hKey,
            string subKey,
            uint options,
            uint sam,
            out UIntPtr phkResult);
        [DllImport("advapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "RegQueryValueExW", SetLastError = true)]
        public static extern int RegQueryValueEx(
            UIntPtr hKey,
            string lpValueName,
            int lpReserved,
            out uint lpType,
            StringBuilder lpData,
            ref uint lpcbData);
        [DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
        [DllImport("kernel32")]
        public static extern IntPtr LoadLibrary(string lpFileName);
    }
}
